import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { TraceRelaTable } from './traceRelaTable.entity';

@Injectable()
export class TraceRelaTableService {
  constructor(
    @InjectRepository(TraceRelaTable)
    private repository: Repository<TraceRelaTable>,
  ) {}


  /**
   * 根据任务id查询
   * @param trace_id 
   * @returns 
   */
  findOne_By_Trace_Id(trace_id: string): Promise<TraceRelaTable>{
    return this.repository.findOne({where:{trace_id:trace_id}})
  }

  findAll(): Promise<TraceRelaTable[]> {
    return this.repository.find();
  }

  findOne(id: any): Promise<TraceRelaTable> {
    return this.repository.findOne(id);
  }

  async remove(id: number): Promise<void> {
    await this.repository.delete(id);
  }

  async create(TraceRelaTable: TraceRelaTable): Promise<void> {
    await this.repository.save(TraceRelaTable);
  }
}
